package frontend

import (
	"AccessAdmin/api/frontend"
	"AccessAdmin/internal/consts"
	"AccessAdmin/internal/service"
	"context"
	"github.com/gogf/gf/v2/util/gconv"
)

// User 用户管理
var User = cUser{}

type cUser struct{}

func (c *cUser) Info(ctx context.Context, req *frontend.UserInfoReq) (res *frontend.UserInfoRes, err error) {
	uid := gconv.Uint(ctx.Value(consts.CtxUserId))
	out, err := service.UserApi().Info(ctx, uid)
	if err != nil {
		return nil, err
	}
	res = &frontend.UserInfoRes{
		UserApi: *out,
	}
	return res, nil
}
